home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / 3dvect39 / argc.asm < prev    next >
Encoding:
Assembly Source File  |  1994-10-30  |  6.1 KB  |  276 lines

  1.          CCHEKSWITCH = 1
  2.          CCHEKSTR = 1
  3.          CCHEKSSTR = 1
  4.          CCMND = 1
  5.          .386p
  6. code32   segment para public use32
  7.          assume cs:code32, ds:code32, ss:code32
  8.  
  9. include  pmode.ext
  10.  
  11. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  12. ; CODE
  13. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  14.  
  15. ;─────────────────────────────────────────────────────────────────────────────
  16. setandchek: ; Set up ES, EDI, ECX and chek length
  17.          mov bx,_selzero
  18.          mov es,bx
  19.          mov edi,_pspa
  20.          add edi,81h
  21.          movzx ecx,byte ptr es:[edi-1]
  22.          cmp cl,ah
  23.          jb setandchekf
  24.          ret
  25. setandchekf: ;  command line too short
  26.          add esp,4
  27.          pop es
  28.          popad
  29.          stc
  30.          ret
  31.  
  32. ;─────────────────────────────────────────────────────────────────────────────
  33. findswitch: ; Find switch AL on command line
  34.          mov ah,al
  35.          mov ebx,edi
  36.          mov ebp,ecx
  37. findswitchl1:
  38.          mov al,'/'
  39.          repnz scasb
  40.          jecxz findswitch2
  41.          mov al,ah
  42.          dec ecx
  43.          scasb
  44.          jne findswitchl1
  45.          ret
  46. findswitch2:
  47.          mov edi,ebx
  48.          mov ecx,ebp
  49. findswitchl2:
  50.          mov al,'-'
  51.          repnz scasb
  52.          jecxz setandchekf
  53.          mov al,ah
  54.          dec ecx
  55.          scasb
  56.          jne findswitchl2
  57.          ret
  58.  
  59. ifdef    CCHEKSWITCH
  60. public   _cchekswitchnc, _cchekswitch
  61. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  62. ; Chek if switch AL entered on command line
  63. ; In:
  64. ;   AL - switch
  65. ; Out:
  66. ;   CF=1 - switch does not exist
  67. ;   CF=0 - switch exists on command line
  68. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  69. _cchekswitchnc:
  70.          cmp al,'A'
  71.          jb short _cchekswitch
  72.          cmp al,'z'
  73.          ja short _cchekswitch
  74.          cmp al,'a'
  75.          jae short cchekswitchncf0
  76.          cmp al,'Z'
  77.          ja short _cchekswitch
  78. cchekswitchncf0:
  79.          push ax
  80.          and al,0dfh
  81.          call _cchekswitch
  82.          pop ax
  83.          jnc _ret
  84.          push ax
  85.          or al,20h
  86.          call _cchekswitch
  87.          pop ax
  88.          ret
  89. _cchekswitch:
  90.          pushad
  91.          push es
  92.          mov ah,3
  93.          call setandchek
  94.          call findswitch
  95.          pop es
  96.          popad
  97.          clc
  98.          ret
  99. endif
  100.  
  101. ifdef    CCHEKSTR
  102. public   _cchekstr
  103. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  104. ; Get _fnt_string number AL
  105. ; In:
  106. ;   AL - _fnt_string number
  107. ;   EDX -> buffer for _fnt_string
  108. ; Out:
  109. ;   CF=1 - _fnt_string not found
  110. ;   CF=0 - _fnt_string found
  111. ;     EDX - ASCIIZ _fnt_string
  112. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  113. _cchekstr:
  114.          pushad
  115.          push es
  116.          mov ah,2
  117.          call setandchek
  118.          inc al
  119.          mov bl,al
  120. chekstrl1:
  121.          mov al,' '
  122.          repnz scasb
  123.          jecxz chekstrf
  124.          mov al,es:[edi]
  125.          cmp al,'-'
  126.          je chekstrl1
  127.          cmp al,'/'
  128.          je chekstrl1
  129.          dec bl
  130.          jnz chekstrl1
  131.          push ds
  132.          mov ax,es
  133.          mov bx,ds
  134.          mov es,bx
  135.          mov ds,ax
  136.          mov esi,edi
  137.          mov edi,edx
  138. chekstrl2:
  139.          lodsb
  140.          stosb
  141.          cmp al,' '
  142.          loopnz chekstrl2
  143.          jnz chekstrf1
  144.          dec edi
  145. chekstrf1:
  146.          xor al,al
  147.          stosb
  148.          pop ds
  149.          pop es
  150.          popad
  151.          clc
  152.          ret
  153. chekstrf:
  154.          pop es
  155.          popad
  156.          stc
  157.          ret
  158. endif
  159.  
  160. ifdef    CCHEKSSTR
  161. public   _ccheksstr
  162. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  163. ; Get _fnt_string associated with switch AL
  164. ; In:
  165. ;   AL - switch
  166. ;   EDX -> buffer for _fnt_string
  167. ; Out:
  168. ;   CF=1 - _fnt_string not found
  169. ;   CF=0 - _fnt_string found or switch does not have _fnt_string
  170. ;     EDX - ASCIIZ _fnt_string
  171. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  172. _ccheksstr:
  173.          pushad
  174.          push es
  175.          mov ah,4
  176.          call setandchek
  177.          call findswitch
  178.          jecxz chekstrf
  179.          cmp byte ptr es:[edi],' '
  180.          je chekstrf
  181.          push ds
  182.          mov ax,es
  183.          mov bx,ds
  184.          mov es,bx
  185.          mov ds,ax
  186.          mov esi,edi
  187.          mov edi,edx
  188. cheksstrl2:
  189.          lodsb
  190.          stosb
  191.          cmp al,' '
  192.          loopnz cheksstrl2
  193.          jnz cheksstrf1
  194.          dec edi
  195. cheksstrf1:
  196.          xor al,al
  197.          stosb
  198.          pop ds
  199.          pop es
  200.          popad
  201.          clc
  202.          ret
  203. endif
  204.  
  205.  
  206. ifdef    CCMND
  207.          public _ccmndsave, _ccmndrestore
  208. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  209. ; Save command line into buffer (doesnt record EXE name)
  210. ; In:
  211. ;  EDX -> buffer for command line
  212. ; Out:
  213. ;  EAX - command line length
  214. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  215.  
  216. _ccmndsave:
  217.          pushad
  218.          push es
  219.          mov ah,2
  220.          call setandchek
  221.  
  222.          push ds
  223.          mov ax,es
  224.          mov bx,ds
  225.          mov es,bx
  226.          mov ds,ax
  227.          mov esi,edi
  228.          mov edi,edx
  229.          mov edx,ecx
  230. shekstrl2:
  231.          lodsb
  232.          stosb
  233.          loop shekstrl2
  234.  
  235.          pop ds
  236.          pop es
  237.          mov [esp+28],edx
  238.          popad
  239.          clc
  240.          ret
  241.  
  242. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  243. ; Save command line into buffer (doesnt record EXE name)
  244. ; In:
  245. ;  EDX -> original command line buffer
  246. ;   AL -  command line length
  247. ; Out: null
  248. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  249.  
  250. _ccmndrestore:
  251.          pushad
  252.          push es
  253.          mov ah,2
  254.          call setandchek
  255.  
  256.          mov byte ptr es:[edi-1],al
  257.          movzx ecx,al
  258.  
  259.          push ds
  260.          mov esi,edx
  261. reskstrl2:
  262.          lodsb
  263.          stosb
  264.          loop reskstrl2
  265.  
  266.          pop ds
  267.          pop es
  268.          popad
  269.          clc
  270.          ret
  271. endif
  272.  
  273. code32   ends
  274.          end
  275.  
  276.